<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--
@html_name: 17map数据结构
@description: The past cannot be redeemed, the future can be changed.
@author: Jason Black
@create: 2023/6/26 09:25:06
-->
<script>
    // 其中map的数据类型不限于String
    let map = new Map();
    // map api
    let student = {
        name: "Jason",
        age: 21,
        sex: "male"
    }
    // add
    map.set("Jason", "my name is Jason")
    map.set(21, student)
    map.set("method", () => {
        console.log("map--method")
    })
    // delete
    console.log(map.get(21))
    console.log(map.get("Jason"))
    console.log(map.get("method")())
    console.log(map)
    // iterator
    for (let element of map) {
        console.log(element)
    }
    map.delete(21)
    console.log(map)
    // size
    console.log(map.size)
    // has
    console.log(map.has("Jason"))
    // clear
    console.log(map)
    map.clear()
    console.log(map)
</script>
</body>
</html>